<!-- Discuss_TeacherReply.html -->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
     <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>讨论详情页</title>
    <link rel="stylesheet" href="../../css/weui.min.css"/>
    <link rel="stylesheet" href="../../css/mui.min.css"/>
    <link rel="stylesheet" href="../../css/base.css">
    <style type="text/css">
    	.current-discuss-tag{
    		line-height: 1em;
    		margin: 0;
    	}
    	.mui-table-view-cell{
    		padding: 10px;
    	}
    	.no-active-cell:active{
    		background-color: white;
    	}
    	.content-p{
    		line-height: 1.4em;
    	}
    	.discuss-img{
    		/*width:-webkit-calc(100%-20px);
			width:-moz-calc(100%-20px);
			width:calc(100%-20px);*/
			max-width: 100%;
    	}
    	.img-div{
    		text-align: center;
    	}
    	
    	.touxiang{
            width: 38px;
            height: 38px;
            border-radius: 19px;
        }
        .nameLabel{
            margin-top: 2px;
        }
        .contentDiv{
            text-overflow: -o-ellipsis-lastline;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            /*-webkit-line-clamp: 3;*/
            -webkit-box-orient: vertical;
            word-wrap: break-word;
        }
        .timeSpan{
            margin-top: 10px;
        }
        .question_detail{
        	background-color: white;
        	padding: 10px;
        	/*border-bottom: 1px solid #ddd;*/
        }
		.rightSpan{
			margin-left: 20px;
		}
		.user-icon-div{
			width: 38px;
			float: left;
		}
		.dis-tag-img{
			width: 12px;
            margin-right: 4px;
		}
		.dis-content-div{
			margin-left: 48px;
		}
        .comment-tag-ul{
            margin-top: 10px;
        }
        .comment-right-tag{
            margin-left: 10px;
        }
        .comment-tag-cell{
            padding: 5px 10px;
        }
        .comment-tag-p{
            height: 20px;
        }
        .bottom-none-div{
            height: 45px;
        }
        .delete-btn{
            /*color: #d81e06;*/
            color: #999;
        }
        .delete-reply-btn{
            /*color: #d81e06;*/
            color: #999;
        }
        .yi-dian-zan{
            color: #18b4ed;
        }
    </style>
</head>
<body>
	<ul id="comment_list" class="mui-table-view">
		<!-- <li class="mui-table-view-cell no-active-cell">
			<div class="user-icon-div">
				<img class="touxiang" src="../../image/default_user_icon.png">
			</div>
			<div class="dis-content-div">
				<label class="nameLabel base_dark_grey base_content_font">提问人</label>
    			<div class="contentDiv base_dark_grey base_content_font">提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容</div>
    			<span class="timeSpan base_grey base_content_font">2017-06-21 12:00</span>
    			<span class="timeSpan rightSpan base_grey base_content_font">
    				<img class="dis-tag-img" src="../../image/icon_zan.png">
    				<span>
    					1729
    				</span>
    			</span>
			</div>
		</li> -->
	</ul>
    <ul class="mui-table-view comment-tag-ul">
        <li class="mui-table-view-cell no-active-cell comment-tag-cell">
            <p class="base_dark_grey base_content_font comment-tag-p">
                <span class="comment-left-tag">
                    全部评论
                </span>
                <span id="reply_num" class="comment-right-tag">
                    0
                </span>
                条
            </p>
        </li>
    </ul>
	<ul id="replyList" class="mui-table-view">
		<!-- <li class="mui-table-view-cell">
			<div class="user-icon-div">
				<img class="touxiang" src="../../image/default_user_icon.png">
			</div>
			<div class="dis-content-div">
				<label class="nameLabel base_dark_grey base_content_font">提问人</label>
    			<div class="contentDiv base_dark_grey base_content_font">提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容提问内容</div>
    			<span class="timeSpan base_grey base_content_font">2017-06-21 12:00</span>
			</div>
		</li> -->
	</ul>
    <div class="noSign"  id="noData"  hidden="hidden">
        <p class="font16 top_15 base_dark_grey" >
            暂无回复
        </p>
    </div>
    <div class="loadFailure" hidden="hidden" id="noNet">
        <p class="" >
            数据加载失败
        </p>
        <p>
            请检查您的网络
        </p>
        <button type="button" class="mui-btn mui-btn-outlined" onclick="loadNewData()">
            重新加载
        </button>
    </div>
    <div id="bottom_none_div" class="bottom-none-div"></div>
    <div id="removeCommentAlert" class="weui_dialog_confirm" style="display: none;">
        <div class="weui_mask"></div>
        <div class="weui_dialog">
            <div class="weui_dialog_hd">
                <strong class="weui_dialog_title">是否确定删除该评论？</strong>
            </div>
            <div class="weui_dialog_bd"></div>
            <div class="weui_dialog_ft">
                <a onclick="cleanCommentCancel()" href="#" class="weui_btn_dialog default">取消</a>
                <a onclick="removeComment()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
            </div>
        </div>
    </div>
    <div id="removeReplyAlert" class="weui_dialog_confirm" style="display: none;">
        <div class="weui_mask"></div>
        <div class="weui_dialog">
            <div class="weui_dialog_hd">
                <strong class="weui_dialog_title">是否确定删除该回复？</strong>
            </div>
            <div class="weui_dialog_bd"></div>
            <div class="weui_dialog_ft">
                <a onclick="cleanReplyCancel()" href="#" class="weui_btn_dialog default">取消</a>
                <a onclick="removeReply()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/MD5.js"></script>
<script type="text/javascript" src="../../script/requestTool.js"></script>
<script type="text/javascript" src="../../script/timeStampTool.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
    var page = 1;
    var rows = 10;
    var dropRefreshCount = 0;
    var replyDatas = new Array();
    var replyDatasObjc = new Object();
    var firstLoad = true;
    var deleteReplyData = null;
    var currentStatus = 1;
	apiready = function(){
        prepareData();
        loadNewData();
        setRefreshHeader();
        setPullUpRefresh();
	    setupInput();
        setupInputShowOrHide();
        setupNotifi();
        bindEnterClick();
        if (api.pageParam.usertype == 'teacher') {
			sendBuriedNotifi('0', '老师端讨论回复页', '209')
		}else{
			sendBuriedNotifi('0', '学生端讨论回复页', '184')
	    }
    }
    
     function sendBuriedNotifi(busionessid, pagetype, pagetypeid) {
			var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
				cid : api.pageParam.cid,
			    pid : api.pageParam.pid
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : api.pageParam.sourceurl,
				sourcetitle : api.pageParam.sourcetitle,
				accesspageurl : window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			SendBehaviorTrajectoriesNotifi_Study(data);
		}
    //监听回车键
    function bindEnterClick(){
        document.onkeydown = function (event) {
        var e = event || window.event;
            if (e && e.keyCode == 13) { //回车键的键值为13
                var inputField = api.require('inputField');
                inputField.getMsg(function(ret, err) {
                    uploadComment(ret.msg);
                });
            }
        }; 
    }
    function setupNotifi(){
        api.addEventListener({
            name: 'pushMessage_classroomMessage'
        }, function(ret, err) {
            var id = ret.value.id;
            if (id == api.pageParam.iid) {
                var activestatus = ret.value.status;
                currentStatus = activestatus;
                setupInputShowOrHide();
            }
        });
        //评论、回复相关消息通知
        api.addEventListener({
            name: 'discussNewMessageNotifi'
        }, function(ret, err) {
            var msgData = ret.value;
            setupPageWithMsgData(msgData);
        });
    }
    //根据消息数据设置页面
    function setupPageWithMsgData(msgData){
        var commentid = msgData.commentid;
        if (api.pageParam.id == commentid) {//当前评论
            var status = msgData.status;
            switch(status){
                case 1://删除评论
                    setupDelComment(msgData);
                    break;
                case 2://评论点赞
                case 3://评论取消点赞
                    refreshLikeNum(msgData);
                    break;
                case 4://添加回复
                    addSingleReply(msgData);
                    break;
                case 5://删除回复
                    delSingleReply(msgData);
                    break;
                default:
            }
        }   
    }
    //添加回复
    function addSingleReply(msgData){
        refreshReplyNum(msgData);//刷新条数
        loadSingleReplyWithMsgData(msgData, function(data){
            if ($('#'+data.id).length>0) {//如果有该条则不添加
                return;
            }
            $('#replyList').prepend(replyHtmlWithData(data));
            addCellClick();
            replyDatasObjc[data.id] = data;
        });
    }
    //加载单条回复
    function loadSingleReplyWithMsgData(msgData, callback){
        var params = {
            // uid : $api.getStorage('cfnetppuid'),
            // jid : $api.getStorage('cfnetppjxid'),
            uid : msgData.pushuid,
            jid : msgData.jid,
            iid : msgData.iid,
            commentid : msgData.commentid,
            replyid : msgData.replyid
        };
        cfnetppPOST(url_DiscussSingleReply, params, false, function(data, status){
            if (status == 'success') {
                if (data.code == 200) {
                    if (callback) {
                        callback(data.data);
                    }
                }
            }
        });
    }
    //删除单条回复时响应
    function delSingleReply(msgData){
        refreshReplyNum(msgData);
        var replyid = msgData.replyid;
        $('#'+replyid).hide();
    }
    //刷新回复数
    function refreshReplyNum(msgData){
        var commentNum = msgData.commentNum;
        if (commentNum == undefined || commentNum == 'undefined' || commentNum == null || commentNum == '') {
            commentNum = 0;
        }
        $('#reply_num').text(commentNum);
    }
    //设置删除
    function setupDelComment(msgData){
        api.toast({
            msg: '当前评论已被删除'
        });
        setTimeout(function(){
            api.closeWin();
        }, 2000);
    }
    //刷新点赞数
    function refreshLikeNum(msgData){
        var praiseNum = msgData.praiseNum;
        if (praiseNum == undefined || praiseNum == 'undefined' || praiseNum == null || praiseNum == '') {
            praiseNum = 0;
        }
        $('#zan_num_span').text(praiseNum);
    }
    function setupInputShowOrHide(){
        var inputField = api.require('inputField');
        if (currentStatus == 1) {//0未开始1开始2关闭3删除
            inputField.show();
            $('#bottom_none_div').removeClass('hide-class');
        }else{
            inputField.hide();
            $('#bottom_none_div').addClass('hide-class');
        }
    }
    function loadNewData() {
        page = 1;
        loadData();
    }
    function loadMoreData() {
        page++;
        loadData();
    }
    //下拉刷新
    function setRefreshHeader() {
        api.setRefreshHeaderInfo({
            visible : true,
            bgColor : '#ccc',
            textColor : '#fff',
            textDown : '下拉刷新...',
            textUp : '松开刷新...',
            showTime : true
        }, function(ret, err) {
            loadNewData();
        });
    }
    // 上拉加载
    function setPullUpRefresh() {
        api.addEventListener({
            name : 'scrolltobottom'
        }, function(ret, err) {
            if (dropRefreshCount >= rows) {
                dropRefreshCount = 0;
                loadMoreData();
            }
        });
    }
    function refreshData(){
        firstLoad = true;
        loadNewData();
    }
    function loadData(){
        if (firstLoad == true) {
            api.showProgress({
                style: 'default',
                animationType: 'fade',
                title: '加载中...',
                text: '',
                modal: false
            });
            firstLoad = false;
        }
        var param = {
            uid : $api.getStorage('cfnetppuid'),
            jid : $api.getStorage('cfnetppjxid'),
            page : page,
            rows : rows,
            commentid : api.pageParam.id
        };
        cfnetppPOST(url_DiscussReplyList, param, true, function(data, status){
            api.refreshHeaderLoadDone();
            api.hideProgress();
            if (status == 'success') {
                if (data.code == 200) {
                    var replyNum = numNullStr(data.data.replyNum);
                    $('#reply_num').text(replyNum);//设置总数
                    var replyArr = data.data.replyList;
                    if (replyArr != null && replyArr.constructor == Array && replyArr.length > 0) {
                        if (page == 1) {//清空数据
                            replyDatasObjc = new Object();
                            replyDatas = new Array();
                        }
                        var currentIndex = replyDatas.length;
                        dropRefreshCount = replyArr.lentgh;
                        replyDatas = replyDatas.concat(replyArr);
                        var replyHtmlString = new String();
                        for (var i = currentIndex; i < replyDatas.length; i++) {
                            var replyData = replyDatas[i];
                            replyDatasObjc[replyData.id] = replyData;
                            replyHtmlString += replyHtmlWithData(replyData);
                        }
                        if (page == 1) {
                            $('#replyList').html(replyHtmlString);
                        }else{
                            $('#replyList').append(replyHtmlString);
                        }
                        addCellClick();
                        $('#noData').hide();
                        $('#noNet').hide();
                    }else{
                        if (page == 1) {
                            $('#replyList').html('');
                            $('#noData').show();
                            $('#noNet').hide();
                        }
                    }
                }else{
                    if (page == 1) {
                        $('#replyList').html('');
                        $('#noData').show();
                        $('#noNet').hide();
                    }
                }
            }else{
                if (page > 1) {
                    page--;
                    dropRefreshCount = rows;
                    api.toast({
                        msg : '网络异常'
                    });
                }else{
                    $('#replyList').html('');
                    $('#noData').hide();
                    $('#noNet').show();
                }
            }
        });
    }
    function replyHtmlWithData(data){
        var userInfo = data.userinfo;
        var userName = '(未知用户)';
        var userIcon = '../../icon/icon_default_HeadPortrait.png';
        var userId = '';
        if (userInfo != null) {
            userName = userInfo.realname;
            userIcon = userInfo.picurl;
            userId = userInfo.uid;
            if (userIcon == null || userIcon == '' || userIcon == 'null') {
                userIcon = '../../icon/icon_default_HeadPortrait.png';
            }
        }
        var deleteBtn = '';
        //自己的可删除
        if (userId == $api.getStorage('cfnetppuid') || api.pageParam.usertype == 'teacher') {
            deleteBtn = '<span replyid="'+data.id+'" class="timeSpan rightSpan base_content_font delete-reply-btn">删除</span>';
        }
        var createtime = data.createtime;
        if (createtime == undefined || createtime == 'undefined' || createtime == null || createtime == '') {
            createtime = getNowDate();
        }
        return '<li id="'+data.id+'" class="mui-table-view-cell reply-cell">'+
            '<div class="user-icon-div">'+
                '<img class="touxiang" src="'+userIcon+'">'+
            '</div>'+
            '<div class="dis-content-div">'+
                '<label class="nameLabel base_dark_grey base_content_font">'+
                    userName+
                '</label>'+
                '<div class="contentDiv base_dark_grey base_content_font">'+
                    data.content+
                '</div>'+
                '<span class="timeSpan base_grey base_content_font">'+
                    timeWithStamp3(createtime)+
                '</span>'+
                deleteBtn+
            '</div>'+
        '</li>';
    }
    function addCellClick(){
        $('.delete-reply-btn').unbind('click');
        $('.delete-reply-btn').click(function(event){
            if (currentStatus != 1) {
                return;
            }
            var replyid = parseInt($(this).attr('replyid'));
            var replyData = replyDatasObjc[replyid];
            deleteReply(replyData);
            event.stopPropagation();
        });
    }
    function cleanCommentCancel(){
        $('#removeCommentAlert').hide();
    }
    function removeComment(){
        $('#removeCommentAlert').hide();
        var param = {
            uid : $api.getStorage('cfnetppuid'),
            jid : $api.getStorage('cfnetppjxid'),
            commentid : api.pageParam.id
        }
        cfnetppPOST(url_DiscussCommentDelete, param, false, function(data, status){
           if(api.pageParam.usertype == 'teacher'){
               SendBusinessOperationsLogNotifi('老师删除讨论', '208', param, param, '', data, '老师删除讨论接口', '208-02');
            }
            if (status == 'success') {
                if (data.code == 200) {
                    api.toast({
                        msg: '删除成功'
                    });
                    api.sendEvent({
                        name: 'deleteDiscussCommentNotifi',
                        extra: {
                            discussid : api.pageParam.id
                        }
                    });
                    api.closeWin({
                        name: 'Discuss_TeacherReplyWin'
                    });
                }else{
                    api.toast({
                        msg: '删除失败'
                    });
                }
            }else{
                api.toast({
                    msg: '删除失败'
                });
            }
        });
    }
    function cleanReplyCancel(){
        $('#removeReplyAlert').hide();
    }
    function removeReply(){
        $('#removeReplyAlert').hide();
        var param = {
            uid : $api.getStorage('cfnetppuid'),
            jid : $api.getStorage('cfnetppjxid'),
            replyid : deleteReplyData.id
        };
        cfnetppPOST(url_DiscussReplyDelete, param, false, function(data, status){
            if(api.pageParam.usertype == 'teacher'){
               SendBusinessOperationsLogNotifi('老师删除讨论回复', '209', param, param, '', data, '老师删除讨论回复接口', '209-02');
            }else{
               SendBusinessOperationsLogNotifi('学生删除讨论回复', '184', param, param, '', data, '学生删除讨论回复接口 ', '184-02');
            }
            if (status == 'success') {
                if (data.code == 200) {
                    $('#' + deleteReplyData.id).remove();
                    if ($('#replyList').html() == '') {
                        $('#noData').show();
                        $('#noNet').hide();
                    }
                    var replyNum = $('#reply_num').text();
                    $('#reply_num').text(parseInt(replyNum) - 1);
                    api.sendEvent({
                        name: 'changeReplyNumNotifi',
                        extra: {
                            commentid : api.pageParam.id,
                            changeStatus : false//true时+1 false时-1
                        }
                    });
                    api.toast({
                        msg: '删除成功'
                    });
                }else{
                    api.toast({
                        msg: data.message
                    });
                }
            }else{
                api.toast({
                    msg: '删除失败'
                });
            }
        });
    }
    function deleteReply(replyData){
        deleteReplyData = replyData;
        $('#removeReplyAlert').show();
    }
    function prepareData(){
        var commentData = api.pageParam;
        currentStatus = commentData.currentStatus;
        $('#comment_list').html(commentHtmlWithData(commentData));
        setCommentCellClick();
    }
    function setupInput(){
        var inputField = api.require('inputField');
        inputField.open({
            bgColor: '#f0f0f0',
            lineColor: '#dedede',
            fileBgColor: '#ffffff',
            borderColor: '#dedede',
            sendImg: 'widget://image/icon_none.png',
            sendImgHighlight: 'widget://image/icon_none.png',
            maxLines: 5,
            placeholder: '评论',
            fixedOn: api.frameName,
            sendBtn: {
                bg: '#f0f0f0',
                bgHighlight: '#f0f0f0',
                title: '发表',
                titleSize: 13,
                titleColor: '#666666'
            },
            placeholderStyles: {
                color: '#999999',
                size: 14,
                marginL: 20
            }
        }, function(ret, err) {
            if (ret) {
                uploadReply(ret.msg);
            }
        });
    }
    function uploadReply(replyContent){
        if (isOnlySpaceOrEnter(replyContent)) {//如果为空
            api.toast({
                msg: '请输入回复内容后再提交'
            });
            return;
        }
        var param = {
            uid : $api.getStorage('cfnetppuid'),
            jid : $api.getStorage('cfnetppjxid'),
            commentid : api.pageParam.id,
            comment : replyContent
        };
        cfnetppPOST(url_DiscussReplyPub, param, false, function(data, status){
            if(api.pageParam.usertype == 'teacher'){
               SendBusinessOperationsLogNotifi('老师发表讨论回复', '209', param, param, '', data, '老师发表讨论回复接口', '209-01');
            }else{
               SendBusinessOperationsLogNotifi('学生发表讨论回复', '184', param, param, '', data, '学生发表讨论回复接口 ', '184-01');
            }
            if (status == 'success') {
                if (data.code == 200) {
                    api.toast({
                        msg: '评论成功'
                    });
                    api.sendEvent({
                        name: 'changeReplyNumNotifi',
                        extra: {
                            commentid : api.pageParam.id,
                            changeStatus : true//true时+1 false时-1
                        }
                    });
                    var inputField = api.require('inputField');
                    inputField.resignFirstResponder();
                    inputField.setMsg({
                        msg: ''
                    }, function(ret, err) {
                    });
                    loadNewData();
                }else{
                    api.toast({
                        msg: data.message
                    });
                    var inputField = api.require('inputField');
                    inputField.setMsg({
                        msg: replyContent
                    }, function(ret, err) {
                    });
                }
            }else{
                api.toast({
                    msg: '评论失败'
                });
                var inputField = api.require('inputField');
                inputField.setMsg({
                    msg: replyContent
                }, function(ret, err) {
                });
            }
        });
    }
    function commentHtmlWithData(data){
        var userInfo = data.userinfo;
        var userName = '(未知用户)';
        var userIcon = '../../icon/icon_default_HeadPortrait.png';
        var userId = '';
        if (userInfo != null) {
            userName = userInfo.realname;
            userIcon = userInfo.picurl;
            userId = userInfo.uid;
            if (userIcon == null || userIcon == '' || userIcon == 'null') {
                userIcon = '../../icon/icon_default_HeadPortrait.png';
            }
        }
        var deleteBtn = '';
        //自己的可删除
        if (userId == $api.getStorage('cfnetppuid') || api.pageParam.usertype == 'teacher') {
            deleteBtn = '<span class="timeSpan rightSpan base_content_font delete-btn">删除</span>';
        }
        var zanClass = '';
        var zanImg = '../../image/icon_zan.png';
        if (data.praiseStatus == 1) {//已点赞
            zanClass = ' yi-dian-zan';
            zanImg = '../../image/icon_zan_select.png';
        }
        return '<li id="'+data.id+'" class="mui-table-view-cell comment-cell">'+
            '<div class="user-icon-div">'+
                '<img class="touxiang" src="'+userIcon+'">'+
            '</div>'+
            '<div class="dis-content-div">'+
                '<label class="nameLabel base_dark_grey base_content_font">'+
                    userName+
                '</label>'+
                '<div class="contentDiv base_dark_grey base_content_font">'+
                    data.content+
                '</div>'+
                '<span class="timeSpan base_grey base_content_font">'+
                    timeWithStamp3(data.createtime.toString())+
                '</span>'+
                '<span id="zanSpan'+data.id+'" praiseStatus="'+data.praiseStatus+'" class="timeSpan rightSpan base_grey base_content_font zan-span">'+
                    '<img class="zan-img dis-tag-img" src="'+zanImg+'">'+
                    '<span id="zan_num_span" class="zan-title'+zanClass+'">'+
                        data.praiseNum+
                    '</span>'+ 
                '</span>'+
                deleteBtn+
            '</div>'+
        '</li>';
    }
    function setCommentCellClick(){
        $('.delete-btn').unbind('click');
        $('.delete-btn').click(function(event){
            if (currentStatus != 1) {
                return;
            }
            deleteComment();
            event.stopPropagation();
        });
        $('.zan-span').unbind('click');
        $('.zan-span').click(function(event){
            if (currentStatus != 1) {
                return;
            }
            var commentData = api.pageParam;
            var praiseStatus = $(this).attr('praiseStatus');
            setPraiseClick(commentData, praiseStatus);
            event.stopPropagation();
        });
    }
    function deleteComment(){
        $('#removeCommentAlert').show();
    }
    //点赞
    function setPraiseClick(commentData, pStatus){
        var praisestatus = 1;//准备点赞
        if (pStatus == 1) {
            praisestatus = 0;//准备取消点赞
        }
        var praiseParam = {
            uid : $api.getStorage('cfnetppuid'),
            jid : $api.getStorage('cfnetppjxid'),
            commentid : commentData.id,
            praisestatus : praisestatus
        }
        cfnetppPOST(url_DiscussCommentPraise, praiseParam, false, function(data, status){
           if(api.pageParam.usertype == 'teacher'){
               SendBusinessOperationsLogNotifi('老师讨论回复点赞', '209', praiseParam, praiseParam, '', data, '老师讨论回复点赞接口', '209-03');
            }else{
               SendBusinessOperationsLogNotifi('学生讨论回复点赞', '184', praiseParam, praiseParam, '', data, '学生讨论回复点赞接口 ', '184-03');
            }
            if (status == 'success') {
                if (data.code == 200) {
                    if (praisestatus == 1) {//点赞成功
                        var praiseDiv = $('#zanSpan' + commentData.id);
                        praiseDiv.attr('praiseStatus', '1');
                        praiseDiv.find('.zan-img').attr('src', '../../image/icon_zan_select.png');
                        var praiseTag = praiseDiv.find('.zan-title');
                        praiseTag.addClass('yi-dian-zan');
                        var currentPraiseNum = numNullStr(praiseTag.text());
                        var praNum = parseInt(currentPraiseNum) + 1;
                        praiseTag.text(praNum);
                        api.sendEvent({
                            name: 'praiseNotifi',
                            extra: {
                                commentid: commentData.id, 
                                praiseStatus: 1,
                                praiseNum: praNum
                            }
                        });
                    }else{//取消点赞
                        var praiseDiv = $('#zanSpan' + commentData.id);
                        praiseDiv.attr('praiseStatus', '0');
                        praiseDiv.find('.zan-img').attr('src', '../../image/icon_zan.png');
                        var praiseTag = praiseDiv.find('.zan-title');
                        praiseTag.removeClass('yi-dian-zan');
                        var currentPraiseNum = numNullStr(praiseTag.text());
                        var praNum = parseInt(currentPraiseNum) - 1;
                        praiseTag.text(praNum);
                        api.sendEvent({
                            name: 'praiseNotifi',
                            extra: {
                                commentid: commentData.id, 
                                praiseStatus: 0,
                                praiseNum: praNum
                            }
                        });
                    }
                }
            }
        });
    }
    function numNullStr(str){
        if (str == null || str == '' || str == undefined) {
            return '0';
        }
        return str;
    }  
</script>
</html>